3 info="$(egrep -o '(^|&)(i=)[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&i=')"
4 edit="$(egrep -o '(^|&)(e=)[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&e=')"
5 rev="$(egrep -o '(^|&)(r=)[0-9]{10}(&|$)' <<<"${QUERY_STRING}" |tr -d '&r=')"
6 search="$(egrep -o '(^|&)(s=).+(&|$)' <<<"${QUERY_STRING}" |sed -r 's:^&?s=::;s:\+: :g;s:%:\\x:g')"
7 search="$(echo -e "${search}" |sed 's:\t: :g;s:\r::g;s:\\:\\\\:g' |head -n1)"
9 [ -n "$rev" ] && rev=".$rev"
10 if [ -n "$search" ]; then
16 lock="Wiki/$info.lock"
17 [ -r "$lock" -o -n "$lock" ] && if [ "$(cut -d: -f2 "$lock")" -lt "$(date +%s)" ]; then
21 lock="$(cut -d: -f1 "$lock")"
24 if [ -n "$edit" -a -r "Wiki/${edit}${rev}" ]; then
25 title="$(egrep -x 'title=.+' "Wiki/$edit.meta" |cut -d= -f2- || echo '(Untitled)')"
27 <form class="edit" action="write/$($LOGIN && echo user_)wikiedit.cgi?i=$edit" method="post" accept-charset="UTF-8">
29 Editing <b>$title</b><br>
30 <input type="submit" value="Submit">
31 <input type="submit" name="cancel" value="Cancel">
37 <textarea name="page" rows=30 cols=40>$(cat "Wiki/${edit}${rev}")</textarea>
42 $(stat -c '' Wiki/${edit}.comment.<0000000000-9999999999>_<000-999> && for each in $(ls -c Wiki/${edit}.comment.<0000000000-9999999999>_<000-999>); do
43 author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
44 echo "<div class='comment'><h1>$author wrote:</h1><div class='wikitext'>"
45 tail -n+2 $each |_wiki
51 elif [ -n "$info" -a -r "Wiki/${info}${rev}" ]; then
52 title="$(egrep -x 'title=.+' "Wiki/$info.meta" |cut -d= -f2- || echo '(Untitled)')"
56 <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
57 <input type="hidden" name="p" value="Wiki">
58 <input type="text" name="s" placeholder="Search"><br>
59 <input type="submit" value="Search Wiki">
64 $(rno=1; for each in Wiki/$info.<0000000000-9999999999>; do
65 revi=$(cut -d. -f2 <<<"$each")
66 echo "<a class='rev' href='?p=Wiki&i=$info&r=$revi'>$rno</a>"
68 done) <a class='rev' href='?p=Wiki&i=$info'>Latest</a><br>
70 $($LOGIN && if [ -z "$lock" ]; then
71 [ -z "$rev" ] && echo "<a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&e=$info'>edit this page</a>"
72 [ -n "$rev" ] && echo "Click <a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&e=${info}&r=${rev:s/.//}'>edit</a> to derive a new page revision from this one."
74 echo "<b>This page is currently being edited by $lock</b><a class='function' href='write/$($LOGIN && echo user_)lock.cgi?p=Wiki&e=$info'>edit anyway</a>"
76 $LOGIN && echo '<hr>')
77 <h1>Table of Content</h1>
79 $(cat Wiki/"${info}${rev}" |while read line; do
80 if (egrep -q '^ *!!!' <<<"$line"); then
81 echo "<a class='i2' href='#$(sed 's,^ *!!! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!!!,,' <<<"$line")</a><br>"
82 elif (egrep -q '^ *!!' <<<"$line"); then
83 echo "<a class='i1' href='#$(sed 's,^ *!! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!!,,' <<<"$line")</a><br>"
84 elif (egrep -q '^ *!' <<<"$line"); then
85 echo "<a class='i0' href='#$(sed 's,^ *! *,,;s,[^a-zA-Z0-9],.,g' <<<"$line")'>$(sed 's,^ *!,,' <<<"$line")</a><br>"
92 <div class="wiki"><div class="wikitext">
94 $(_wiki Wiki/"${info}${rev}")
99 echo '<div id="RIGHT">'
100 $LOGIN && cat <<WikiEND
101 <a id='comment_button' class='function' href='#' onclick='javascript:show_screen("comment");hide_screen("comment_button");'>Comment / Ask</a>
102 <div id="comment" style="display: none;">
103 <form action="/write/$($LOGIN && echo user_)wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
105 <textarea name="comm" rows="6" style="width:99%;"></textarea><br>
106 <input type="submit" value="Submit">
107 <a class="function" href="#" onclick="javascript:hide_screen('comment');show_screen('comment_button');">Cancel</a>
111 stat -c '' Wiki/${info}.comment.<0000000000-9999999999>_<000-999> && for each in $(ls -c Wiki/${info}.comment.<0000000000-9999999999>_<000-999>); do
112 author=$(grep -m1 '^author=' "$each" |cut -d= -f2-)
113 echo "<div class='comment'><h1>$author wrote:</h1><div class='wikitext'>"
114 tail -n+2 $each |_wiki
119 elif [ -z "$info" ]; then
122 <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
123 <input type="hidden" name="p" value="Wiki">
124 <input type="text" name="s" placeholder="Search"><br>
125 <input type="submit" value="Search Wiki">
129 if [ -n "$search" ]; then
130 echo "<h1>Wiki search results for: $search</h1>"
131 for each in $(grep -ile "$search" Wiki/<0000000000-9999999999>_<000-999>); do
132 echo "<div class='search'><a href='?p=Wiki&i=${each:t}'><h2>$(grep '^title=' "$each.meta" |cut -d= -f2-)</h2></a>"
133 grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
138 echo '</div><div id="RIGHT">'
139 $LOGIN && cat <<WikiEND
140 <a id='addp_button' class='function' href='#' onclick='javascript:show_screen("add_page");hide_screen("addp_button");'>Add a new Page</a>
141 <div id="add_page" style="display: none;">
142 <form action="/write/$($LOGIN && echo user_)wikimeta.cgi" method="post" accept-charset="UTF-8">
143 <br><b>Title:</b><br>
144 <input type="text" name="title" placeholder="Fill in a title"><br>
145 <b>Description:</b><br>
146 <textarea name="desc" rows="6" ></textarea><br>
147 <input type="submit" value="Submit">
148 <a class="function" href="#" onclick="javascript:hide_screen('add_page');show_screen('addp_button');">Cancel</a>
152 echo '</div><div id="MAIN">'
154 stat -c '' Wiki/<0000000000-9999999999>_<000-999> && for each in Wiki/<0000000000-9999999999>_<000-999>; do
155 info=$(sed 's,Wiki/,,' <<<"$each")
156 title="$(egrep -x 'title=.+' "$each.meta" |cut -d= -f2- || echo '(Untitled)')"
157 description="$(egrep -x 'description=.+' "$each.meta" |cut -d= -f2-)"
158 owner="$(egrep -x 'owner=.+' "$each.meta" |cut -d= -f2-)"
161 <div class="article">
162 <div id="display_$info">
163 <a name="$info" href="/?p=Wiki&i=$info"><h1>$title</h1></a>
165 <a class="function" href="/?p=Wiki&i=$info">View</a>
166 $($ACL_WIKIEDIT && echo "<a class='function' href='#' onclick=\"javascript:show_screen('change_$info');hide_screen('display_$info');\">Change Info</a>")
169 $ACL_WIKIEDIT && cat <<WikiEND
170 <div id="change_$info" style="display: none;">
171 <form action="/write/$($LOGIN && echo user_)wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
172 <b>Title:</b> <input type="text" name="title" value="$title"><br>
173 <b>Description:</b><br>
174 <textarea name="desc" rows="6" style="width:100%;">$description</textarea><br>
175 <input type="submit" value="Submit">
176 <a class="function" href="#" onclick="javascript:hide_screen('change_$info');show_screen('display_$info');">Cancel</a>